﻿using System;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraBars;
using DevExpress.XtraGrid.Views.Grid;
using UniMana.Data;
using UniMana.Utils.Controls;
using UniMana.Utils.Data;
using UniMana.Utils.Helper;
namespace UniMana.Win.Leadership
{
    public partial class FrmReport_SubSubjectList : DevExpress.XtraEditors.XtraForm
    {
        private DBMain m_ReportSubjetcList = new DBMain();
        private bds m_bds;
        private const int ACTION_NO = 0;
        public FrmReport_SubSubjectList()
        {
            InitializeComponent();
            InitControlEvent();
        }
        public void InitControlEvent()
        {
            this.xucBar1.btnPrint_Click += 
                new UniMana.Utils.Controls.xucBar.ButtonClickHandler(
                    this.btnPrint_Click);
            //this.xucBar1.btnExport_Click += 
            //new UniMana.Utils.Controls.xucBar.ButtonClickHandler(
            //    this.btnExportExcel_Click);
        }
        private void btnPrint_Click(object sender, ItemClickEventArgs e)
        {
            FrmReport_RptSubjectList view1 = new FrmReport_RptSubjectList(this.m_bds);
            
            view1.ShowPreview();
        }

        private void FrmReportSubjectList_Load(object sender, EventArgs e)
        {
            lueCatalogue_Department.GetData(
                (m_ReportSubjetcList.m_DCReadOnly.Catalogue_Departments.Where(p=>p.SubjectManage==true)),
                "Catalogue_DepartmentKey", 
                "Name");
        }

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            switch (keyData)
            {
                case Keys.Enter:
                     this.m_bds = new bds();
                     this.m_bds.DataSource = 
                         m_ReportSubjetcList.m_DCReadOnly.Training_Subjects.CaSubjectList(
                         m_ReportSubjetcList.m_DCReadOnly.Catalogue_Departments,
                         m_ReportSubjetcList.m_DCReadOnly.Catalogue_SubjectTypes, 
                         m_ReportSubjetcList.m_DCReadOnly.Training_TrainingProgram_Details,
                         m_ReportSubjetcList.m_DCReadOnly.Training_SubjectGroups, 
                         this.lueCatalogue_Department.GetIntValue());
                     this.grcSubjectList.DataSource = this.m_bds;
                    return true;
                default:
                    break;
            }

            return base.ProcessCmdKey(ref msg, keyData);
        }
        /// <summary>
        /// xem môn học
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
          private void btnView_Click(object sender, EventArgs e)
          {
              this.m_bds = new bds();
              this.m_bds.DataSource = 
                  m_ReportSubjetcList.m_DCReadOnly.Training_Subjects.CaSubjectList(
                  m_ReportSubjetcList.m_DCReadOnly.Catalogue_Departments,
                  m_ReportSubjetcList.m_DCReadOnly.Catalogue_SubjectTypes, 
                  m_ReportSubjetcList.m_DCReadOnly.Training_TrainingProgram_Details,
                  m_ReportSubjetcList.m_DCReadOnly.Training_SubjectGroups,
                  this.lueCatalogue_Department.GetIntValue());
              this.grcSubjectList.DataSource = this.m_bds;
             
          }

          private void grvSubjectList_RowStyle(object sender, RowStyleEventArgs e)
          {
              //GridView View = sender as GridView;

              //if (e.RowHandle >= 0)
              //{
              //    string category = View.GetRowCellDisplayText(e.RowHandle, View.Columns["TenLoaiMH"]);
              //    if (category == "Môn bắt buộc")
              //    {
              //        e.Appearance.BackColor = Color.SkyBlue;
              //        e.Appearance.BackColor2 = Color.SkyBlue;
              //    }
              //}
          }

        

    }
}